<?
/*
 *   Pmail easy way to send emails
 *   Copyright (C) 2009  Felipe Theodoro Gonçalves (www.ftgoncalves.com)
 *
 *   This program is free software: you can redistribute it and/or modify
 *	 it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
?>
<div id="page">
<p class="ind"><?= $html->link(__d('pmail', 'See groups configured', true), array('plugin' => 'pmail', 'controller' => 'groups', 'action' => 'index')); ?> > <?= __d('pmail', 'Edit group') ?></p>
	<h2>Edit Group : <?= $name[0]['Group']['name'] . ' ' .  $html->image('/pmail/img/iconeEditar.gif', array('alt' => 'Edit name group', 'class' => 'pointer','border' => 0, 'onclick' => '$("#container_edit").toggle();')) ?></h2>
	<div class="hide" id="container_edit">
		<form action="<?= $html->url(array('plugin' => 'pmail', 'controller' => 'groups', 'action' => 'edit_name_group', 'id' => $this->params['pass'][0])) ?>" method="post" enctype="application/x-www-form-urlencoded">
			<fieldset>
				<legend><?= __d('pmail', 'data group') ?></legend>
					<p>
						<label for="name"><?= __d('pmail', 'Identifier') ?></label>
						<br/>
						<?= $form->text('Group.name', array('class' => 'big', 'maxlength' => 60)); ?>
					</p>
					<p>
						<label for="description"><?= __d('pmail', 'Description') ?></label>
						<br/>
						<?= $form->textarea('Group.description', array('rows' => 8, 'class' => 'select_big')) ?>
					</p>
					<p>
						<?= $form->submit(__d('pmail', 'save', true), array('value' => 'Save', 'class' => 'button')) ?>
					</p>
			</fieldset>
		</form>
	</div>
	<table>
		<caption class="left"><?= __d('pmail', 'List of members') ?></caption>
		<thead>
			<tr>
				<th scope="col"><?= __d('pmail', 'Member') ?></th>
				<th scope="col"><?= __d('pmail', 'Email') ?></th>
				<th scope="col"><?= __d('pmail', 'Option') ?></th>
			</tr>
		</thead>
		<tbody>
			<?php
				$count = 0;
				foreach($members as $aux){
					foreach($aux as $member){
						echo '<tr id="' . $count++ . '">';
							echo '<td>' . $member['name'] . '</td>';
							echo '<td>' . $member['email'] . '</td>';
							echo '<td>';
								echo $html->link($html->image('/pmail/img/iconeEditar.gif', array('alt' => 'Editar', 'border' => 0)), array('plugin' => 'pmail', 'controller' => 'groups', 'action' => 'edit_member', 'id' => $member['id']), array(), false, false);
						  		echo $html->link($html->image('/pmail/img/iconeExcluir.gif', array('alt' => 'Excluir', 'border' => 0)), array('plugin' => 'pmail', 'controller' => 'groups', 'action' => 'delete_member', 'id' => $member['id']), array(), __d('pmail', 'Are you sure you want to delete this member', true), false);
							echo '</td>';
						echo '</tr>';
					}
				}
			?>
		</tbody>
	</table>
	( <?= __d('pmail', 'import') ?> csv: <?= $html->link($html->image('/pmail/img/upload.gif', array('border' => 0)), 'javascript:void(0);', array('id' => 'import_button'), false, false) ?> )
	<div id="import" class="hide">
		<form action="<?= $html->url(array('plugin' => 'pmail', 'controller' => 'groups', 'action' => 'import_members', 'id' => $this->params['pass'][0])) ?>" method="post" enctype="multipart/form-data">
			<fieldset>
				<legend><?= __d('pmail', 'Import') ?> CSV</legend>
					<p>
						<label for="file"><?= __d('pmail', 'File') ?></label>
						<br/>
						<?= $form->file('Pmail.file') ?>
					</p>
					<p>
						<?= $form->submit(__d('pmail', 'send', true), array('class' => 'button')) ?>
					</p>
			</fieldset>
		</form>
	</div>
</div>
<div id="sidebar">
	<h4><?= __d('pmail', 'Coments') ?></h4>
	<p><?= __d('pmail', 'View and edit the group members') ?>.</p>
	<?= $this->requestAction('/pmail/groups/menu') ?>
	<?= $this->renderElement('recommended/links') ?>
</div>
<div class="clear"></div>
<script type="text/javascript">
	$().ready(function(){
		$('table tbody tr:odd').addClass('impar');
	});

	$('#import_button').click(function(){
		$('#import').toggle();
	});
</script>